package com.uchengwang.functions.db.manager;

import android.content.Context;

import com.litesuits.orm.db.model.ColumnsValue;
import com.uchengwang.ui.cm_ui.cycle.bean.RyGroupBean;

import java.util.List;


/**
 * Created by U城网 on 2017/10/24.
 */

public class GroupDBManager {
    private static GroupDBManager manager;
    private GroupDBManager(){}

    public static GroupDBManager getManager() {
        if (manager == null){
            manager = new GroupDBManager();
        }
        return manager;
    }

    /**
     * 根据群ID 更新本地群信息
     * */
    public void updateGroupInfo(Context context, long groupId, ColumnsValue value){
        List<RyGroupBean> list = LiteOrmDBUtil.getLiteOrm(context).getQueryAll(RyGroupBean.class);
        if (list != null && list.size() >0){
            for (RyGroupBean bean : list){
                if (groupId == bean.getId()){
                    LiteOrmDBUtil.getLiteOrm(context).update(RyGroupBean.class, value, "id", groupId);
                    return;
                }
            }
        }
    }
}
